using System;
using System.Data;
using System.Xml;

using OR.Reuse.Persistence;

using Derived = OR.Lazarus.Business.Entities.Notation;

namespace OR.Lazarus.Business.Entities.Notation.Lazarus
{
	/// <summary>
	/// Defines a type and associated notation prefix.
	/// </summary>
   public class MapDetail : EntityBase
   {
		protected System.String mName;
		protected string mTarget;
		protected string mDescription;

		public MapDetail()
		{
	
		}
	
		/// <summary>
		/// 
		/// </summary>
		public System.String Name
		{
			get
			{
				return ( mName );
			}
			set
			{
				mName = value;
			}
		}

		/// <summary>
		/// 
		/// </summary>
		public string Target
		{
			get
			{
				return ( mTarget );
			}
			set
			{
				mTarget = value;
			}
		}

		/// <summary>
		/// 
		/// </summary>
		public string Description
		{
			get
			{
				return ( mDescription );
			}
			set
			{
				mDescription = value;
			}
		}

		public override void LoadXml( XmlElement pSource )
		{
			// Scalar Values
			mName = DataUtility.GetString( pSource, "name" );
			mTarget = DataUtility.GetString( pSource, "target" );
			XmlElement vDescription = ( XmlElement )pSource.SelectSingleNode( "description", PersistenceConfig.Namespaces );
			
			if ( vDescription != null )
			{
				mDescription = vDescription.InnerText;
			}
			
		}
		
		public override XmlElement SaveXml( XmlDocument p_docContext )
		{
			XmlElement vNewElement	= p_docContext.CreateElement( "", "map", "" );

			// Scalar Values
			if ( !String.IsNullOrEmpty( mName ) )
			{
				vNewElement.SetAttribute( "name", mName );
			}
					
			if ( !String.IsNullOrEmpty( mTarget ) )
			{
				vNewElement.SetAttribute( "target", mTarget );
			}
					
			if ( !String.IsNullOrEmpty( mDescription ) )
			{
				XmlElement	vDescription = p_docContext.CreateElement( "", "description", "" );
				vDescription.InnerText = mDescription;
				vNewElement.AppendChild( vDescription );
			}
					

			return ( vNewElement );
		}

		public virtual object Clone()
		{
			Derived.MapDetail v_oReturn = new Derived.MapDetail();
			
			v_oReturn.Name = mName;
			v_oReturn.Target = mTarget;
			v_oReturn.Description = mDescription;
			
			// FK Values

			// Collections
			
			return ( v_oReturn );
		}

		public virtual Derived.MapDetail CloneTyped()
		{
			return ( ( Derived.MapDetail )this.Clone() );
		}
   }
}
   